﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Zero.UControl.Component
{
    /// <summary>
    /// UMessageBox.xaml 的交互逻辑
    /// </summary>
    public partial class UMessageBox : Window
    {
        public UMessageBox()
        {
            InitializeComponent();
            MouseLeftButtonDown += UMessageBox_MouseLeftButtonDown;
        }

        private void UMessageBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }

        private string dialogTitle = "标题";

        public string DialogTitle
        {
            get { return dialogTitle; }
            set 
            {
                dialogTitle = value;
                lb.Content = dialogTitle;
            }
        }

        private string iconPath;

        public string IconPath
        {
            get { return iconPath; }
            set 
            {
                iconPath = value;
                Img.Source = new BitmapImage(new Uri(iconPath,UriKind.Absolute));
            }
        }

        private string message;

        public string Message
        {
            get { return message; }
            set 
            {
                message = value;
                lbMsg.Text = message;
            }
        }

        public Action<bool> DoAction { get; set; }

        private void Close_Button_Click(object sender, RoutedEventArgs e)
        {
            DoAction?.Invoke(false);
            this.DialogResult = false;
        }

        private void Confirm_Button_Click(object sender, RoutedEventArgs e)
        {
            DoAction?.Invoke(true);
            this.DialogResult = true;
        }
    }
}
